package com.back.demo.service;

import com.back.demo.controller.myVO.StudentVO.StudentPositionVO;
import com.back.demo.controller.myVO.StudentVO.StudentPracticeVO;
import com.back.demo.controller.myVO.StudentVO.StudentResearchVO;
import com.back.demo.mapper.StudentMapper;
import com.back.demo.common.StudentInfo;
import com.back.demo.mapper.myDO.StudentDO.StudentPositionDO;
import com.back.demo.mapper.myDO.StudentDO.StudentPracticeDO;
import com.back.demo.mapper.myDO.StudentDO.StudentResearchDO;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;

@org.springframework.stereotype.Service
public class StudentService {
    @Autowired
    private StudentMapper studentMapper;

    public StudentInfo findStudentInfoByStudentId(String studentId) {
        return studentMapper.selectStudentInfoByStudentId(studentId);
    }

    public void changeStudentInfo(String username, String phone, String email) {
        studentMapper.changeStudentInfo(username, phone, email);
    }

    // 个人学年总结
    // 个人学年总结
    // 个人学年总结
    public String findStudentSummaryByStudentId(String studentId) {
        return studentMapper.selectStudentSummaryByStudentId(studentId);
    }

    public void addStudentSummary(String studentId, String summary) {
        studentMapper.updateStudentSummary(studentId, summary);
    }
    // 个人学年总结
    // 个人学年总结
    // 个人学年总结

    // 科研情况
    // 科研情况
    // 科研情况
    public ArrayList<StudentResearchVO> findStudentResearchByStudentId(String studentId) {
        ArrayList<StudentResearchDO> listDO = studentMapper.selectStudentResearchByStudentId(studentId);
        ArrayList<StudentResearchVO> listVO = new ArrayList<>();
        for (StudentResearchDO researchDO : listDO) {
            StudentResearchVO researchVO = new StudentResearchVO();
            researchVO.setId(researchDO.getId());
            researchVO.setResearchType(researchDO.getResearchType());
            researchVO.setResearchTime(researchDO.getResearchTime());
            researchVO.setResearchName(researchDO.getResearchName());
            researchVO.setResearchContent(researchDO.getResearchContent());
            listVO.add(researchVO);
        }
        return listVO;
    }

    public void addStudentResearchByStudentId(String studentId, StudentResearchVO reqVO) {
        StudentResearchDO reqDO = new StudentResearchDO();
        reqDO.setResearchType(reqVO.getResearchType());
        reqDO.setResearchTime(reqVO.getResearchTime());
        reqDO.setResearchName(reqVO.getResearchName());
        reqDO.setResearchContent(reqVO.getResearchContent());
        studentMapper.insertStudentResearchByStudentId(studentId, reqDO.getResearchType(), reqDO.getResearchTime(), reqDO.getResearchName(), reqDO.getResearchContent());
    }

    public void modifyStudentResearchById(StudentResearchVO reqVO) {
        StudentResearchDO reqDO = new StudentResearchDO();
        reqDO.setId(reqVO.getId());
        reqDO.setResearchType(reqVO.getResearchType());
        reqDO.setResearchTime(reqVO.getResearchTime());
        reqDO.setResearchName(reqVO.getResearchName());
        reqDO.setResearchContent(reqVO.getResearchContent());
        studentMapper.updateStudentResearchById(reqDO.getId(), reqDO.getResearchType(), reqDO.getResearchTime(), reqDO.getResearchName(), reqDO.getResearchContent());
    }

    public void deleteStudentResearchById(Integer id) {
        studentMapper.deleteStudentResearchById(id);
    }

    // 科研情况
    // 科研情况
    // 科研情况

    // 社会实践
    // 社会实践
    // 社会实践
    public ArrayList<StudentPracticeVO> findStudentPracticeByStudentId(String studentId) {
        ArrayList<StudentPracticeDO> listDO = studentMapper.selectStudentPracticeByStudentId(studentId);
        ArrayList<StudentPracticeVO> listVO = new ArrayList<>();
        for (StudentPracticeDO practiceDO : listDO) {
            StudentPracticeVO practiceVO = new StudentPracticeVO();
            practiceVO.setId(practiceDO.getId());
            practiceVO.setPracticeDate(practiceDO.getPracticeDate());
            practiceVO.setPracticeName(practiceDO.getPracticeName());
            practiceVO.setPracticeSponsor(practiceDO.getPracticeSponsor());
            practiceVO.setPracticeTheme(practiceDO.getPracticeTheme());
            practiceVO.setPracticeWork(practiceDO.getPracticeWork());
            practiceVO.setPracticeLength(practiceDO.getPracticeLength());
            listVO.add(practiceVO);
        }
        return listVO;
    }

    public void addStudentPracticeByStudentId(String studentId, StudentPracticeVO reqVO) {
        StudentPracticeDO reqDO = new StudentPracticeDO();
        reqDO.setPracticeDate(reqVO.getPracticeDate());
        reqDO.setPracticeName(reqVO.getPracticeName());
        reqDO.setPracticeSponsor(reqVO.getPracticeSponsor());
        reqDO.setPracticeTheme(reqVO.getPracticeTheme());
        reqDO.setPracticeWork(reqVO.getPracticeWork());
        reqDO.setPracticeLength(reqVO.getPracticeLength());
        studentMapper.insertStudentPracticeByStudentId(studentId, reqDO.getPracticeDate(), reqDO.getPracticeName(), reqDO.getPracticeSponsor(), reqDO.getPracticeTheme(), reqDO.getPracticeWork(), reqDO.getPracticeLength());
    }

    public void modifyStudentPracticeById(StudentPracticeVO reqVO) {
        StudentPracticeDO reqDO = new StudentPracticeDO();
        reqDO.setId(reqVO.getId());
        reqDO.setPracticeDate(reqVO.getPracticeDate());
        reqDO.setPracticeName(reqVO.getPracticeName());
        reqDO.setPracticeSponsor(reqVO.getPracticeSponsor());
        reqDO.setPracticeTheme(reqVO.getPracticeTheme());
        reqDO.setPracticeWork(reqVO.getPracticeWork());
        reqDO.setPracticeLength(reqVO.getPracticeLength());
        studentMapper.updateStudentPracticeById(reqDO);
    }

    public void deleteStudentPracticeById(Integer id) {
        studentMapper.deleteStudentPracticeById(id);
    }

    // 社会实践
    // 社会实践
    // 社会实践

    // 学生骨干服务岗位
    // 学生骨干服务岗位
    // 学生骨干服务岗位
    public ArrayList<StudentPositionVO> findStudentPositionByStudentId(String studentId) {
        ArrayList<StudentPositionDO> listDO = studentMapper.selectStudentPositionByStudentId(studentId);
        ArrayList<StudentPositionVO> listVO = new ArrayList<>();
        for (StudentPositionDO positionDO : listDO) {
            StudentPositionVO positionVO = new StudentPositionVO();
            positionVO.setId(positionDO.getId());
            positionVO.setPositionName(positionDO.getPositionName());
            positionVO.setPositionStartDate(positionDO.getPositionStartDate());
            positionVO.setPositionEndDate(positionDO.getPositionEndDate());
            positionVO.setPositionReport(positionDO.getPositionReport());
            listVO.add(positionVO);
        }
        return listVO;
    }

    public void addStudentPositionByStudentId(String studentId, StudentPositionVO reqVO) {
        StudentPositionDO reqDO = new StudentPositionDO();
        reqDO.setPositionName(reqVO.getPositionName());
        reqDO.setPositionStartDate(reqVO.getPositionStartDate());
        reqDO.setPositionEndDate(reqVO.getPositionEndDate());
        reqDO.setPositionReport(reqVO.getPositionReport());
        studentMapper.insertStudentPositionByStudentId(studentId, reqDO.getPositionName(), reqDO.getPositionStartDate(), reqDO.getPositionEndDate(), reqDO.getPositionReport());
    }

    public void modifyStudentPositionById(StudentPositionVO reqVO) {
        StudentPositionDO reqDO = new StudentPositionDO();
        reqDO.setId(reqVO.getId());
        reqDO.setPositionName(reqVO.getPositionName());
        reqDO.setPositionStartDate(reqVO.getPositionStartDate());
        reqDO.setPositionEndDate(reqVO.getPositionEndDate());
        reqDO.setPositionReport(reqVO.getPositionReport());
        studentMapper.updateStudentPositionById(reqDO);
    }

    public void deleteStudentPositionById(Integer id) {
        studentMapper.deleteStudentPositionById(id);
    }
    // 学生骨干服务岗位
    // 学生骨干服务岗位
    // 学生骨干服务岗位

}
